#define  _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include <time.h>
#include <stdlib.h>
void menu()
{
    printf("############################\n");
    printf("#########1.开始游戏#########\n");
    printf("############################\n");
    printf("#########0.结束游戏#########\n");
    printf("############################\n");
    printf("############################\n");
}
void game()
{
    int num = rand() % 100 + 1;//rand函数会随机生成一个0-37000左右的随机数
    while (1)
    {
        int guess = 0;
        printf("请猜一个数字:");
        scanf("%d", &guess);
        if (guess > num)
        {
            printf("猜大了\n");
        }
        else if (guess < num)
        {
            printf("猜小了\n");
        }
        else
        {
            printf("恭喜你猜对了\n");
            break;
        }
    }
}
int main()
{
    int i = 0;
    srand((unsigned int)time(NULL));
    do
    {
        menu();
        printf("请选择：");
        scanf("%d", &i);
        switch (i)
        {
        case 1:
            game();
        case 0:
            printf("游戏结束\n");
            break;
        default:
            printf("输入错误，请重新输入");
        }
    } while (i);

    return 0;
}